home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 45 / CD-ROM 45 / CD-ROM 45.iso / aplicat / dominio / Dominio / Disk1 / DOMINIO.BAK < prev    next >
Encoding:
Text File  |  1998-09-13  |  14.6 KB  |  540 lines

  1. '**************************************************************************
  2. '*                       MSSetup Toolkit Sample 2
  3. '**************************************************************************
  4.  
  5. '$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST ASKQUIT      = 200
  12. CONST DESTPATH     = 300
  13. CONST EXITFAILURE  = 400
  14. CONST EXITQUIT     = 600
  15. CONST EXITSUCCESS  = 700
  16. CONST OPTIONS      = 800
  17. CONST APPHELP      = 900
  18. CONST CUSTINST     = 6200
  19. CONST TOOBIG       = 6300
  20. CONST BADPATH      = 6400
  21.  
  22. ''Bitmap ID
  23. CONST LOGO         = 1
  24.  
  25. ''File Types
  26. CONST APPFILES     = 1
  27. CONST OPCIONAIS    = 2
  28. 'CONST OPTFILES2    = 3
  29.  
  30.  
  31. GLOBAL DEST$        ''Default destination directory.
  32. GLOBAL WINDRIVE$    ''Windows drive letter.
  33. GLOBAL OPT1OPT$     ''Option selection from OPCIONAIS option dialog.
  34. 'GLOBAL OPT2OPT$     ''Option selection from OptFiles2 option dialog.
  35.  
  36. ''CustInst list symbol names
  37. GLOBAL APPNEEDS$    ''Option list costs per drive
  38. GLOBAL OPT1NEEDS$
  39. GLOBAL OPT2NEEDS$
  40. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  41. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  42.  
  43. ''Dialog list symbol names
  44. GLOBAL CHECKSTATES$
  45. GLOBAL STATUSTEXT$
  46. GLOBAL DRIVETEXT$
  47.  
  48.  
  49. DECLARE SUB AddOptFilesToCopyList (ftype%)
  50. DECLARE SUB RecalcOptFiles (ftype%)
  51. DECLARE SUB RecalcPath
  52. DECLARE SUB SetDriveStatus
  53. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  54.  
  55.  
  56. ' maximizando a janela
  57. ''following were taken from windows.h. &H means they're hex
  58. CONST WS_VISIBLE=&H10000000
  59. CONST WS_BORDER =&H00800000
  60. CONST WS_CLIPCHILDREN =&H02000000
  61. CONST GWL_STYLE =-16
  62. CONST SW_SHOWMAXIMIZED=3
  63.  
  64. DECLARE FUNCTION ShowWindow  LIB "user.exe" (hWnd%,iShow%) AS INTEGER
  65. DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG     ''this declaration must all be on one line
  66.  
  67. hWnd%=HwndFrame()
  68. i1&=SetWindowLong(hWnd%,GWL_STYLE,WS_VISIBLE+WS_BORDER+WS_CLIPCHILDREN)
  69. j1%=ShowWindow(hWnd%,SW_SHOWMAXIMIZED)
  70. 'fim
  71.  
  72.  
  73.  
  74. INIT:
  75.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  76.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  77.  
  78.     SetBitmap CUIDLL$, LOGO
  79.     SetTitle "Instalaτπo do Software Domφnio"
  80.  
  81.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  82.     IF szInf$ = "" THEN
  83.         szInf$ = GetSymbolValue("STF_CWDDIR") + "DOMINIO.INF"
  84.     END IF
  85.     ReadInfFile szInf$
  86.  
  87.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  88.     DEST$ = WINDRIVE$ + ":\DOMINIO"
  89.  
  90.     ''CustInst list symbols
  91.     CHECKSTATES$ = "CheckItemsState"
  92.     STATUSTEXT$  = "StatusItemsText"
  93.     DRIVETEXT$   = "DriveStatusText"
  94.     FOR i% = 1 TO 3 STEP 1
  95.         AddListItem CHECKSTATES$, "ON"
  96.     NEXT i%
  97.     FOR i% = 1 TO 3 STEP 1
  98.         AddListItem STATUSTEXT$, ""
  99.     NEXT i%
  100.     FOR i% = 1 TO 7 STEP 1
  101.         AddListItem DRIVETEXT$, ""
  102.     NEXT i%
  103.     ReplaceListItem DRIVETEXT$, 7, DEST$
  104.  
  105.     ''Disk cost list symbols
  106.     APPNEEDS$   = "AppNeeds"
  107.     OPT1NEEDS$  = "Opt1Needs"
  108.     OPT2NEEDS$  = "Opt2Needs"
  109.     EXTRACOSTS$ = "ExtraCosts"
  110.     BIGLIST$    = "BigList"
  111.     FOR i% = 1 TO 3 STEP 1
  112.         AddListItem BIGLIST$, ""
  113.     NEXT i%
  114.     FOR i% = 1 TO 26 STEP 1
  115.         AddListItem EXTRACOSTS$, "0"
  116.     NEXT i%
  117.  
  118.     ''File Option Variables
  119.     OPT1OPT$ = "1"
  120. '    OPT2OPT$ = "1"
  121.  
  122.     RecalcPath
  123.     SetDriveStatus
  124.  
  125. '$IFDEF DEBUG
  126.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  127. '$ENDIF ''DEBUG
  128.  
  129.  
  130.  
  131. CUSTINST:
  132.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  133.  
  134.     IF sz$ = "CONTINUE" THEN
  135.         ''Install only if it will fit.
  136.         FOR i% = 1 TO 3 STEP 1
  137.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  138.                 GOSUB TOOBIG
  139.                 GOTO CUSTINST
  140.             END IF
  141.         NEXT i%
  142.         UIPop 1
  143.         GOTO INSTALL
  144.     ELSEIF sz$ = "PATH" THEN
  145.         GOTO GETPATH
  146.     ELSEIF sz$ = "CHK1" THEN
  147.         RecalcOptFiles APPFILES
  148.         SetDriveStatus
  149.         GOTO CUSTINST
  150.     ELSEIF sz$ = "CHK2" THEN
  151.         RecalcOptFiles OPCIONAIS
  152.         SetDriveStatus
  153.         GOTO CUSTINST
  154. '    ELSEIF sz$ = "CHK3" THEN
  155. '    RecalcOptFiles OPTFILES2
  156. '    SetDriveStatus
  157. '    GOTO CUSTINST
  158.     ELSEIF sz$ = "BTN2" THEN
  159.     GOTO OPCIONAIS
  160. '    ELSEIF sz$ = "BTN3" THEN
  161. '    GOTO OPTFILES2
  162.     ELSEIF sz$ = "REACTIVATE" THEN
  163.         RecalcPath
  164.         SetDriveStatus
  165.         GOTO CUSTINST
  166.     ELSE
  167.         GOSUB ASKQUIT
  168.         GOTO CUSTINST
  169.     END IF
  170.  
  171.  
  172.  
  173. INSTALL:
  174.     ClearCopyList
  175.     AddOptFilesToCopyList APPFILES
  176.     AddOptFilesToCopyList OPCIONAIS
  177. '    AddOptFilesToCopyList OPTFILES2
  178.     CreateDir DEST$, cmoNone
  179.     CopyFilesInCopyList
  180.  
  181.     IF GetListItem(CHECKSTATES$, OPCIONAIS) = "ON" THEN
  182.     ini$ = MakePath(DEST$, "CEPSFULL.ALN")
  183. '    CreateIniKeyValue "WIN.INI", "Habilite-se!", "CEPFULLFile", OPT1OPT$, cmoNone
  184.     CreateIniKeyValue "WIN.INI", "Dominio", "CEPFULLFile", ini$, cmoNone
  185. '    CreateIniKeyValue ini$, "Section 1", "Key 1", "Value 1" , cmoNone
  186. '    CreateIniKeyValue ini$, "Section 2", "Key 2", "Value 2" , cmoNone
  187. '    CreateIniKeyValue ini$, "Section 3", "Key 3", "Value 3" , cmoNone
  188.         ini$ = ""
  189.     END IF
  190.  
  191.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  192.     CreateProgmanGroup "Domφnio", "Dominio.grp", cmoNone
  193.     ShowProgmanGroup  "Domφnio", 1, cmoNone
  194.     CreateProgmanItem "Domφnio", "Domφnio", MakePath(DEST$,"dominio.exe"), "", cmoOverwrite
  195.     CreateProgmanItem "Domφnio", "Botπo Domφnio", MakePath(DEST$,"dombotao.exe"), "", cmoOverwrite
  196.         'CreateProgmanItem "MSSetup Sample 2", "dlgprocs.c", "notepad.exe "+MakePath(DEST$,"dlgprocs.c"), "", cmoOverwrite
  197.     END IF
  198.  
  199.  
  200. QUIT:
  201.     ON ERROR GOTO ERRQUIT
  202.  
  203.     IF ERR = 0 THEN
  204.         dlg% = EXITSUCCESS
  205.     ELSEIF ERR = STFQUIT THEN
  206.         dlg% = EXITQUIT
  207.     ELSE
  208.         dlg% = EXITFAILURE
  209.     END IF
  210. QUITL1:
  211.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  212.     IF sz$ = "REACTIVATE" THEN
  213.     GOTO QUITL1
  214.     END IF
  215.     prgmdpath$ = MakePath(DEST$,"")
  216.     dirinst$ = CURDIR$("")
  217.     prgmd$ = MakePath(DEST$,"dominio.exe ") + "$cabaτo$"
  218.     ' + prgmdpath$
  219. ' Ap≤s saφda OK, executa o Domφnio para habilitar a instalaτπo
  220.     IF dlg% = EXITSUCCESS THEN
  221.        RUN prgmd$, NOWAIT
  222. '    RUN MakePath(DEST$,"dominio.exe"), NOWAIT
  223.     END IF
  224. 'DoMsgBox(dirinst$, "Domφnio - Mensagem", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  225.     UIPop 1
  226.     END
  227.  
  228. ERRQUIT:
  229.     i% = DoMsgBox("Arquivos adulterados. Chame (051) 2285468!", "Domφnio - Mensagem", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  230.     END
  231.  
  232.  
  233.  
  234. GETPATH:
  235.     SetSymbolValue "EditTextIn", DEST$
  236.     SetSymbolValue "EditFocus", "END"
  237. GETPATHL1:
  238.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  239.  
  240.     IF sz$ = "CONTINUE" THEN
  241.         olddest$ = DEST$
  242.         DEST$ = GetSymbolValue("EditTextOut")
  243.  
  244.         ''Validate new path.
  245.         IF IsDirWritable(DEST$) = 0 THEN
  246.             GOSUB BADPATH
  247.             GOTO GETPATHL1
  248.         END IF
  249.         UIPop 1
  250.  
  251.         ''Truncate display if too long.
  252.         IF LEN(DEST$) > 23 THEN
  253.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  254.         ELSE
  255.             ReplaceListItem DRIVETEXT$, 7, DEST$
  256.         END IF
  257.  
  258.         ''Recalc if path changed.
  259.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  260.             RecalcPath
  261.             SetDriveStatus
  262.         END IF
  263.  
  264.         olddest$ = ""
  265.         GOTO CUSTINST
  266.     ELSEIF sz$ = "REACTIVATE" THEN
  267.         RecalcPath
  268.         SetDriveStatus
  269.         GOTO GETPATHL1
  270.     ELSEIF sz$ = "EXIT" THEN
  271.         GOSUB ASKQUIT
  272.         GOTO GETPATHL1
  273.     ELSE
  274.         UIPop 1
  275.         GOTO CUSTINST
  276.     END IF
  277.  
  278.  
  279.  
  280. OPCIONAIS:
  281.     SetSymbolValue "RadioDefault", OPT1OPT$
  282. OPT1L1:
  283.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  284.     newopt$ = GetSymbolValue("ButtonChecked")
  285.  
  286.     IF sz$ = "CONTINUE" THEN
  287.         UIPop 1
  288.         IF newopt$ <> OPT1OPT$ THEN
  289.             OPT1OPT$ = newopt$
  290.         RecalcOptFiles OPCIONAIS
  291.             SetDriveStatus
  292.         END IF
  293.         newopt$ = ""
  294.         GOTO CUSTINST
  295.     ELSEIF sz$ = "REACTIVATE" THEN
  296.         RecalcPath
  297.         SetDriveStatus
  298.         GOTO OPT1L1
  299.     ELSEIF sz$ = "EXIT" THEN
  300.         GOSUB ASKQUIT
  301.         GOTO OPT1L1
  302.     ELSE
  303.         UIPop 1
  304.         newopt$ = ""
  305.         GOTO CUSTINST
  306.     END IF
  307.  
  308.  
  309.  
  310. OPTFILES2:
  311.     SetSymbolValue "RadioDefault", OPT2OPT$
  312. OPT2L1:
  313.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  314.     newopt$ = GetSymbolValue("ButtonChecked")
  315.  
  316.     IF sz$ = "CONTINUE" THEN
  317.         UIPop 1
  318.         IF newopt$ <> OPT2OPT$ THEN
  319.             OPT2OPT$ = newopt$
  320.             RecalcOptFiles OPTFILES2
  321.             SetDriveStatus
  322.         END IF
  323.         newopt$ = ""
  324.         GOTO CUSTINST
  325.     ELSEIF sz$ = "REACTIVATE" THEN
  326.         RecalcPath
  327.         SetDriveStatus
  328.         GOTO OPT2L1
  329.     ELSEIF sz$ = "EXIT" THEN
  330.         GOSUB ASKQUIT
  331.         GOTO OPT2L1
  332.     ELSE
  333.         UIPop 1
  334.         newopt$ = ""
  335.         GOTO CUSTINST
  336.     END IF
  337.  
  338.  
  339.  
  340. TOOBIG:
  341.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  342.     IF sz$ = "REACTIVATE" THEN
  343.         RecalcPath
  344.         SetDriveStatus
  345.         GOTO TOOBIG
  346.     END IF
  347.     UIPop 1
  348.     RETURN
  349.  
  350.  
  351.  
  352. BADPATH:
  353.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  354.     IF sz$ = "REACTIVATE" THEN
  355.         RecalcPath
  356.         SetDriveStatus
  357.         GOTO BADPATH
  358.     END IF
  359.     UIPop 1
  360.     RETURN
  361.  
  362.  
  363.  
  364. ASKQUIT:
  365.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  366.  
  367.     IF sz$ = "EXIT" THEN
  368.         UIPopAll
  369.         ERROR STFQUIT
  370.     ELSEIF sz$ = "REACTIVATE" THEN
  371.         GOTO ASKQUIT
  372.     ELSE
  373.         UIPop 1
  374.     END IF
  375.     RETURN
  376.  
  377.  
  378.  
  379. '**
  380. '** Purpose:
  381. '**     Adds the specified option files to the copy list.
  382. '** Arguments:
  383. '**     ftype%  - type of files to add, one of the following:
  384. '**             APPFILES, OPCIONAIS, OPTFILES2
  385. '** Returns:
  386. '**     none.
  387. '*************************************************************************
  388. SUB AddOptFilesToCopyList (ftype%) STATIC
  389.  
  390.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  391.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  392.         IF ftype% = APPFILES THEN
  393.         AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  394.     ELSEIF ftype% = OPCIONAIS THEN
  395.         AddSectionKeyFileToCopyList "OPCIONAIS", OPT1OPT$, SrcDir$, DEST$
  396. '    ELSEIF ftype% = OPTFILES2 THEN
  397. '        AddSectionKeyFileToCopyList "OptFiles2", OPT2OPT$, SrcDir$, DEST$
  398.         END IF
  399.         SrcDir$ = ""
  400.     END IF
  401. END SUB
  402.  
  403.  
  404. '**
  405. '** Purpose:
  406. '**     Recalculates disk space for the given option files and sets
  407. '**     the status info symbol "StatusItemsText".
  408. '** Arguments:
  409. '**     ftype% - type of files to add, one of the following:
  410. '**             APPFILES, OPCIONAIS, OPTFILES2
  411. '** Returns:
  412. '**     none.
  413. '*************************************************************************
  414. SUB RecalcOptFiles (ftype%) STATIC
  415.     CursorSave% = ShowWaitCursor()
  416.     ClearCopyList
  417.     AddOptFilesToCopyList ftype%
  418.  
  419.     fExtra% = 0
  420.     IF ftype% = APPFILES THEN
  421.         ListSym$ = APPNEEDS$
  422.         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  423.             ''Add extra cost to Windows drive for ini/progman, etc.
  424.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  425.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  426.             fExtra% = 1
  427.         END IF
  428.     ELSEIF ftype% = OPCIONAIS THEN
  429.         ListSym$ = OPT1NEEDS$
  430. '    ELSEIF ftype% = OPTFILES2 THEN
  431. '    ListSym$ = OPT2NEEDS$
  432.     END IF
  433.  
  434.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  435.  
  436.     cost& = 0
  437.     FOR i% = 1 TO 26 STEP 1
  438.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  439.     NEXT i%
  440.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  441.  
  442.     IF StillNeed& > 0 THEN
  443.         ReplaceListItem BIGLIST$, ftype%, "YES"
  444.     ELSE
  445.         ReplaceListItem BIGLIST$, ftype%, ""
  446.     END IF
  447.  
  448.     IF fExtra% THEN
  449.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  450.     END IF
  451.     RestoreCursor CursorSave%
  452.     ListSym$ = ""
  453. END SUB
  454.  
  455.  
  456. '**
  457. '** Purpose:
  458. '**     Recalculates disk space and sets option status info according
  459. '**     to the current destination path.
  460. '** Arguments:
  461. '**     none.
  462. '** Returns:
  463. '**     none.
  464. '*************************************************************************
  465. SUB RecalcPath STATIC
  466.  
  467.     CursorSave% = ShowWaitCursor()
  468.  
  469.     RecalcOptFiles APPFILES
  470.     RecalcOptFiles OPCIONAIS
  471. '    RecalcOptFiles OPTFILES2
  472.  
  473.     RestoreCursor CursorSave%
  474. END SUB
  475.  
  476.  
  477. '**
  478. '** Purpose:
  479. '**     Sets drive status info according to latest disk space calcs.
  480. '** Arguments:
  481. '**     none.
  482. '** Returns:
  483. '**     none.
  484. '*************************************************************************
  485. SUB SetDriveStatus STATIC
  486.  
  487.     drive$ = MID$(DEST$, 1, 1)
  488.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  489.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
  490.     ' + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  491.     free& = GetFreeSpaceForDrive(drive$)
  492.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  493.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  494.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  495.  
  496.     IF drive$ = WINDRIVE$ THEN
  497.         ReplaceListItem DRIVETEXT$, 4, ""
  498.         ReplaceListItem DRIVETEXT$, 5, ""
  499.         ReplaceListItem DRIVETEXT$, 6, ""
  500.     ELSE
  501.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  502.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
  503.     ' + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  504.         IF cost& = 0 THEN
  505.             ReplaceListItem DRIVETEXT$, 4, ""
  506.             ReplaceListItem DRIVETEXT$, 5, ""
  507.             ReplaceListItem DRIVETEXT$, 6, ""
  508.         ELSE
  509.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  510.         ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  511.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  512.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  513.         END IF
  514.     END IF
  515. END SUB
  516.  
  517.  
  518. '**
  519. '** Purpose:
  520. '**     Appends a file name to the end of a directory path,
  521. '**     inserting a backslash character as needed.
  522. '** Arguments:
  523. '**     szDir$  - full directory path (with optional ending "\")
  524. '**     szFile$ - filename to append to directory
  525. '** Returns:
  526. '**     Resulting fully qualified path name.
  527. '*************************************************************************
  528. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  529.     IF szDir$ = "" THEN
  530.         MakePath = szFile$
  531.     ELSEIF szFile$ = "" THEN
  532.         MakePath = szDir$
  533.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  534.         MakePath = szDir$ + szFile$
  535.     ELSE
  536.         MakePath = szDir$ + "\" + szFile$
  537.     END IF
  538. END FUNCTION
  539.  
  540.